$(function() {
});

var residue;
var endTime;

function doSearch() {
	var startTime = $('#startTime').datebox('getValue');
	endTime = $('#endTime').datebox('getValue');
	var province = $('#province').combobox('getValue');
	
	if (startTime == "" && endTime != "") {
		$.messager.alert(market.content.title, "请选择开始时间！");
	}
	
	$.ajax({
		url : '/migu/miguUserMonitor',
		data : {
			startTime : startTime,
			endTime : endTime,
			province : province
		},
		type : "POST",
		datatype : "json",
		//contentType: "application/x-www-form-urlencoded; charset=utf-8", 
		async : true,
		success : function(data) {
			residue = JSON.stringify(data.residue);
			drawChart(data);
		}
	});
}

google.charts.load('current', {'packages':['corechart']});


function drawChart(data) {
	var arr = data.charts;
    var data = google.visualization.arrayToDataTable(arr);
    
    var options = {
        title: endTime + '帐号剩余量 ：' + residue,
        curveType: 'function',
        legend: { position: 'bottom' },
        pointSize: 7
     };
    
    var chart = new google.visualization.LineChart(document.getElementById('chart_div'));

    chart.draw(data, options);
}
